package org.arabidopsis.plantCyc;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class RegexTestHarness {

public static void main(String[] args){
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

while (true) {
try {
System.out.println("\nEnter your regex:\n ");
Pattern pattern =
Pattern.compile(in.readLine());
System.out.println("\nEnter input string to search:\n ");
Matcher matcher =
pattern.matcher(in.readLine());

boolean found = false;
while (matcher.find()) {

String output = String.format("I found the text \"%s\" starting at " +
"index %d and ending at index %d.%n",
matcher.group(), matcher.start(), matcher.end());
System.out.println(output);
found = true;
}
if(!found){
System.out.println("No match found.\n");
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}